var xmlHttp;
var xmlHttpTango;

function showCustomer(str, op, id)
{ 	
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
			{
				alert ("Your browser does not support AJAX!");
				return;
			}
			 
	var url = "ajax.php";
	url = url + "?q=" + str;
	url = url + "&op=" + op;
	url = url + "&id=" + id;
	url = url + "&sid=" + Math.random();
	if (op == 11 || op == 12 || op == 13 || op == 14 || op == 15 || op == 16 || op == 17 || op == 18)
		xmlHttp.onreadystatechange = stateChangedBis;
	else
		xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showCustomerTango(str, op, id)
{ 	
	xmlHttpTango = GetXmlHttpObject();
	if (xmlHttpTango == null)
			{
				alert ("Your browser does not support AJAX!");
				return;
			}
			 
	var url = "ajaxTango.php";
	url = url + "?q=" + str;
	url = url + "&op=" + op;
	url = url + "&id=" + id;
	url = url + "&sid=" + Math.random();
	xmlHttpTango.onreadystatechange = stateChangedTango;
	xmlHttpTango.open("GET",url,true);
	xmlHttpTango.send(null);
}

function stateChangedBis() 
{ 
	if (xmlHttp.readyState == 4)
	{ 
		document.getElementById("txtHint").innerHTML = xmlHttp.responseText;
		bEstadoCodigo = true;
		if (xmlHttp.responseText != "Codigo EXISTENTE")
			bCodigoReady = true;
		else
			bCodigoReady = false;
		submitea();
	}
}

function stateChanged() 
{ 
	if (xmlHttp.readyState == 4)
	{ 
		document.getElementById("txtHint").innerHTML = xmlHttp.responseText;
		if (xmlHttp.responseText != "Codigo EXISTENTE")
			document.frm.submit();
	}
}

function submitea()
{
	if (bCodigoReady == true && bCodigoTReady == true)
		document.frm.submit();
}

function stateChangedTango() 
{ 
	if (xmlHttpTango.readyState == 4)
	{ 
		document.getElementById("txtHintTango").innerHTML = xmlHttpTango.responseText;
		bEstadoCodigoTango = true;
		if (xmlHttpTango.responseText != "Codigo TANGO YA ASIGNADO")
			bCodigoTReady = true;
		else
			bCodigoTReady = false;
		submitea();
	}
}

function GetXmlHttpObject()
{
	var xmlHttp = null;
	try
			{
	 		// Firefox, Opera 8.0+, Safari
				xmlHttp = new XMLHttpRequest();
			}
	catch (e)
			{
				// Internet Explorer
				try
  			{
  				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  			}
				catch (e)
  			{
  				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  			}
			}
	return xmlHttp;
}